home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 16 / AMIGAplus Sonderheft 16 (1998)(ICP)(DE)[!].iso / pd / anwendungen / ispell-3.1.18bin / interfaces / mg / spell-word.mg < prev   
Text File  |  1995-09-21  |  2KB  |  66 lines

  1. /*
  2.  * QAD hack to use the ispell ARexx port to check the spelling of the
  3.  * word you just typed, or are pointing at. Type a ? to get a list of possible
  4.  * replacements, and then either type the word, or the number of the
  5.  * replacement in the list.
  6.  *
  7.  * Copyright (c) 1990, Mike Meyer
  8.  */
  9.  
  10. options results
  11.  
  12. /* Get the word & and a running IRexx... */
  13. if ~show(ports, 'IRexxSpell') then address command 'run ispell -r >nil:'
  14. word = getword()
  15. if word = "" then exit 2
  16. address command 'waitforport IRexxSpell'
  17.  
  18. /* Check it, exiting if it's in the dictionary */
  19. address 'IRexxSpell' 'check' word
  20. list = result
  21. type = left(list, 1)
  22. if type = '*' then exit
  23.  
  24. /* otherwise, offer to let the user replace it */
  25. do forever
  26.     'rexx-request "`'word''' not recognized; replacement: "'
  27.     if rc > 0 then exit
  28.     if result ~= "?" then leave
  29.     if type = '#' then iterate
  30.     else do
  31.         'rexx-request "'substr(list, 3)': "'
  32.         if rc = 0 then do
  33.             if datatype(result, 'Numeric') then
  34.                 result = word(list, result + 1)
  35.             leave
  36.             end
  37.         end
  38.     end
  39. replace = result
  40.  
  41. /* We have a replacement from the user - go install it... */
  42. 'forward-char'
  43. 'backward-word'
  44. 'kill-word'
  45. 'rexx-insert "'replace'"'
  46. exit
  47.  
  48.  
  49. /* Old version - replaces everything in the buffer */
  50. 'rexx-point' point
  51. if point.0 < 2 then exit 2
  52. 'beginning-of-buffer'
  53. 'search-forward "'word'"'
  54.  
  55. /* Really need to make query-replace work inside of rexx... */
  56. do while rc = 0
  57.     'backward-kill-word'
  58.     'rexx-insert "'replace'"'
  59.     'search-forward "'word'"'
  60.     end
  61.  
  62. /* Put things back... */
  63. 'goto-line' point.1
  64. 'beginning-of-line'
  65. 'search-forward "'replace'"'
  66.